<div class="row">
	<div class="col-md-12 bg-success">
		<h4 class="text-success">投标数据维护</h4>
	</div>
</div>

<div class="bid-list-for-edit">
	<table class="bid-list" data-page="${page}" data-page-size="${pageSize}" data-count="${count}">
		<tr class="title-row">
			<th class="text-center" width="50">序号</th>
			<th class="text-center" width="250">投标编号</th>
			<th class="text-center" width="250">招标编号</th>
			<th class="text-center">招标名称</th>
		</tr>
		<#if data??> <#list data as d>
		<tr class="data" data-id="${d[0]}" style="cursor: pointer;">
			<td class="text-center">${d_index+1}</td>
			<td class="text-center">${d[1]}</td>
			<td class="text-center">${d[2]}</td>
			<td>${d[3]}</td>
		</tr>
		</#list> </#if>
	</table>
</div>

<script src="${request.contextPath}/js/suredy-list.js"></script>
<script type="text/javascript">
	var refresh = function() {
		$.suredy.loadContent('${request.contextPath}/dm/search', null, {
			page : '${page}',
			pageSize : '${pageSize}',
			key : '${key}',
			type : '${type}'
		});
	};

	$(function() {
		$('tr.data>td').on('click', function() {
			var id = $(this).parent().data('id');
			window.open('${request.contextPath}/dm/bid-edit/' + id);
		});

		$('.bid-list').list({
			search : false,
			checkbox : true,
			paginate : function(page, pageSize, key) {
				$.suredy.loadContent('${request.contextPath}/dm/search', null, {
					page : page,
					pageSize : pageSize,
					key : '${key}',
					type : '${type}'
				});
			},
			btns : [ {
				text : '删除',
				style : 'btn-danger btn-sm',
				click : function() {
					var trs = $.suredy.list.checked($('.bid-list'));
					var ids = [];

					if (!trs || trs.length < 1) {
						alert('请选择需要删除的数据！');
						return false;
					}

					trs.each(function(i) {
						ids[ids.length] = $(this).data('id');
					});

					var msg = '数据删除后将无法恢复，是否任然确认删除？';

					if (!window.confirm(msg))
						return false;

					$.suredy.showProcessDialog({
						keyboard : false,
						text : '<div class="text-danger"><i class="icon-spinner icon-spin"></i>&nbsp;正在删除数据，请稍候……</div>'
					});

					$.ajax({
						url : '${request.contextPath}/dm/bid-del',
						type : 'post',
						traditional : true,
						data : {
							ids : ids
						},
						success : function(data, textStatus, jqXHR) {
							if (!data || !data.success) {
								alert(data.msg || '投标信息删除失败！');
								$.suredy.closeProcessDialog();
								return false;
							}

							refresh();

							$.suredy.closeProcessDialog();
						},
						error : function(jqXHR, textStatus, errorThrown) {
							alert('投标信息删除失败！\n' + errorThrown);
							$.suredy.closeProcessDialog();
							return false;
						}
					});
				}
			}, {
				text : '返回',
				style : 'btn-success btn-sm',
				click : function() {
					$.suredy.loadContent('${request.contextPath}/dm?type=b');
				}
			} ]
		});
	});
</script>